﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace DSTMEETING.Win.App
{
    class HttpClientFactory
    {
        private static CookieContainer s_cookieContainer;

        public static HttpClient Create()
        {
            var handler = new HttpClientHandler();
            if (s_cookieContainer != null)
            {
                handler.CookieContainer = s_cookieContainer;
            }

            HttpClient client = new HttpClient(handler);
            client.BaseAddress = new Uri(Config.Instance.ServerBaseUrl);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            return client;
        }

        public static void UpdateCookieContianer(CookieContainer cookieContainer)
        {
            s_cookieContainer = cookieContainer;
        }
    }
}
